package top.houry.netty.barrage.service.impl;

import cn.hutool.core.util.StrUtil;
import com.google.protobuf.TextFormat;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import top.houry.netty.barrage.annotation.BarrageAnnotation;
import top.houry.netty.barrage.consts.BarrageMsgTypeConst;
import top.houry.netty.barrage.proto.BarrageProto;
import top.houry.netty.barrage.service.IBarrageMsgTypeService;

import java.util.HashMap;
import java.util.Map;

/**
 * @Desc
 * @Author houruiyang
 * @Date 2022/1/22
 **/
@Service
@BarrageAnnotation(msgType = BarrageMsgTypeConst.WEB_CLIENT_COMMENT_REQ)
@Slf4j
public class BarrageMsgCommentServiceImpl implements IBarrageMsgTypeService {


    @Override
    public void dealWithBarrageMessage(BarrageProto.Barrage barrage, ChannelHandlerContext ctx) {
        try {
            BarrageProto.WebClientCommentReq commentReq = BarrageProto.WebClientCommentReq.parseFrom(barrage.getBytesData());
            log.info("Req-BarrageMsgCommentServiceImpl-dealWithBarrageMessage-params:{}",  TextFormat.printToUnicodeString(commentReq));
            int size = commentReq.getSize();
            int page = commentReq.getPage();


        } catch (Exception e) {
            log.error("Exception-BarrageMsgCommentServiceImpl-dealWithBarrageMessage", e);
        }
    }

}
